package com.example.mqdemo.PointToPoint.annotationType;

import jakarta.annotation.Resource;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;

/*
 *@description: 点对点队列消息发送者注解版
 *@author: hisen
 *@Time: 2023/11/20  22:50
 */
@Component
public class PointToPointProducer {

    @Resource
    private AmqpTemplate amqpTemplate;

    public void sendMessage(String message) {
        // 发送消息到名为 "point_to_point" 的队列
        amqpTemplate.convertAndSend("point_to_point", message);
        System.out.println("发送消息: " + message);
    }
}
